package com.cainaer.orders.controller;


import com.cainaer.common.core.web.domain.AjaxResult;
import com.cainaer.orders.domain.Orders;
import com.cainaer.orders.service.IOrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author Tina
 * @since 2020-09-11
 */
@RestController
@RequestMapping("/")
public class OrdersController {

    @Autowired
    private IOrdersService ordersService;

    /**
     * 新增订单
     *
     * @param order
     * @return
     */
    @PostMapping("add")
    public AjaxResult insertOrders(@RequestBody Orders order) {
        return AjaxResult.success(ordersService.insertOrders(order));
    }

    /**
     * 查询订单
     *
     * @param orders
     * @return
     */
    @GetMapping("list")
    public AjaxResult queryOrders(Orders orders) {
        return AjaxResult.success(ordersService.queryOrders(orders));
    }

    @GetMapping("orderAmount")
    public Integer selectOrderAmountByShopId(@RequestParam("shopId") Long shopId){
        return ordersService.querySalesVolumeByShopId(shopId);
    };
}
